package com.soft.javase.day07.loginexception;

import javax.swing.*;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/26
 */
public class UserService {

    public static void main(String[] args) {
        try {
            System.out.println(login(1L, "123456"));
        } catch (LoginException e) {
            System.out.println(e.getMessage());
        }
    }

    public static boolean login(Long id, String password) throws LoginException {
        if (id == null || password == null || password.equals("")) {
            throw  new LoginException("账户或密码不能为空");
        }
        if (id.equals(1L) && password.equals("123456")) {
            //JOptionPane.showMessageDialog(null,"登陆成功");
            return true;
        }
        throw new LoginException("账户与密码不匹配");
    }
}
